const { DataTypes } = require('sequelize');

// const sequelize = require("@/db/seq");
const sequelize = require("@/db/seq");
const Role_Menus = sequelize.define("role_menus",{
  role_id: {
    type: DataTypes.INTEGER,
    references: {
      model: 'blog_roles',
      key: 'id'
    },
    onDelete: 'CASCADE'
  },
  menu_id: {
    type: DataTypes.INTEGER,
    references: {
      model: 'blog_menus',
      key: 'id'
    },
    onDelete: 'CASCADE'
  },    

})
Role_Menus.associate = (models) => {
  Role_Menus.belongsTo(models.blog_roles, {
    foreignKey: 'role_id',
    as: 'role'
  });
  Role_Menus.belongsTo(models.blog_menus, {
    foreignKey: 'menu_id',
    as: 'menu'
  });
}
// Role_Menus.sync({ force: false, alter: true });
module.exports = Role_Menus;